var HtmlWebpackPlugin = require('html-webpack-plugin');
var htmlPluginConfig = new HtmlWebpackPlugin({
	template: 'index.html',
	filename: 'index.html',
	inject: 'body',
	favicon: 'tit_icon1.png'
});
var NgMin = require('ng-annotate-webpack-plugin');
var ngMinConfig = new NgMin({add: true});
var path = require('path');

module.exports = {
    entry: [
        './module/index.js'
    ],
    module: {
        loaders: [
			{
				test: /\.html$/,
				loader: 'ng-cache?module=LM&prefix=[dir]/[dir]',
				include: [
					path.resolve(__dirname, 'module')
				]
			},
            {test: /\.less$/, loader: 'style!css!less'},
			{test: /\.css$/, loader: 'style!css'},
			{
				test: /\.png$/, 
				loader: 'url-loader?limit=10000&name=res/[hash].[ext]',
				include: path.resolve(__dirname, 'module')
			},
			{test: /\.svg$/, loader: 'url-loader', include: path.resolve(__dirname, 'module')},
			{
				test: /\.jpg$/,
				loader: 'url-loader?limit=10000&name=res/[hash].[ext]',
				include: path.resolve(__dirname, 'module')
			},
			// bootstrap
			{ test: /\.woff$/,   loader: "file?mimetype=application/font-woff&name=res/[hash].[ext]" },
			{ test: /\.woff2$/,   loader: "file?mimetype=application/font-woff2&name=res/[hash].[ext]" },
			{ test: /\.ttf$/,    loader: "file?mimetype=application/octet-stream&name=res/[hash].[ext]" },
			{ test: /\.eot$/,    loader: "file?name=res/[hash].[ext]" },
			{ test: /regular\.svg$/,    loader: "file?name=res/[hash].[ext]&mimetype=image/svg+xml" }
        ]
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'output')
    },
    plugins: [
		htmlPluginConfig,
		ngMinConfig
	]
};
